import { getMaintenancerRequest } from "@/apis/mainTenancer"
import { makeAutoObservable } from "mobx"
import { makePersistable } from "mobx-persist-store"
export interface mainrType {
	username: string,
	password: string,
	phone: string,
	name: string
	id: number
}

export class mainTenancerStore {
	maintenancers: mainrType[] = []
	constructor() {
		makeAutoObservable(this, {}, { autoBind: true })
		makePersistable(this, {
			name: 'mainTenancerStore',
			properties: ['maintenancers'],
			storage: window.localStorage,
		})
	}

	setMaintenancers(m: mainrType[]) {
		this.maintenancers = m
	}

	getMaintenancers() {
		getMaintenancerRequest().then((res: any) => {
			this.setMaintenancers(res.result)
		})
	}
}